<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">
			
		</style>
	</head>
	<body>
		<div id="div1">
			<ul>
				<li>第一个li</li>
				<p>段落1</p>
				<li>第二个li</li>
				<li>第三个li</li>
				<p>超链接</p>
				<li>第四个li</li>
			</ul>
		</div>
		<div id="div2">
						
		</div>
		<script type="text/javascript">
			//获取节点
			var div1=document.getElementById("div1");
			var div2=document.getElementById("div2");
			//获取子节点
			var ul1=div1.firstElementChild;
			document.write(ul1);
			//获取ul的所有子节点
			var li=ul1.childNodes;
			document.write("<br />"+li);
			document.write("<br />遍历子节点")
			for (var i in li){
				document.write("<br />"+li[i])
			}
			var ulf=ul1.parentNode;
			document.write("<br />获取ul的父节点<br />"+ulf);
			var li2=ul1.firstElementChild.nextElementSibling;
			document.write("<br />获取ul的第二个节点<br />"+li2);
			var li3=ul1.lastElementChild.previousSibling.nextElementSibling;
			document.write("<br />获取ul的倒数第二个节点<br />"+li3);
		</script>
	</body>
</html>
